<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/H5asset/css/swiper.min.css"/>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/H5asset/css/common.css"/>
	<script src="__PUBLIC__/H5asset/js/jquery-2.1.0.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/H5asset/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" href="__PUBLIC__/H5asset/css/pullToRefresh.css"/>
	<script src="__PUBLIC__/H5asset/js/iscroll.js"></script>
	<script src="__PUBLIC__/H5asset/js/pullToRefresh.js"></script>
	<title>商户评论</title>
</head>
<body>
<div id="wrapper">
	<ul class="seller_mes">

	</ul>
</div>
<script type="text/javascript">
    // 加载控件
    refresher.init({
        id:"wrapper",
        pullDownAction:Refresh,
        pullUpAction:Load
    });
    
	var id = "{$merch_id}";// demo 41

    var result="",pageNo = 2,pageSize = 16,max_id = 0;

    //var total_page = 1;

    //下拉刷新
    function Refresh() {
        $.ajax({
            url:'/ApiWF/Merch/h5CommentPullDownRefresh',
            type:'POST',
            data:{page_size:pageSize,mid:id,max_id:max_id},
            success:function(data){
                if(max_id<=data.data.max_id){
                    for (i=0; i<data.data.list.length; i++) {
                        var avatar_url = data.data.list[i].avatar;
                        avatar_url = avatar_url.length > 1 ? avatar_url : '/public/H5asset/images/default_avatar.png';

                        result+="<li><dl class='cf'><dt><img src ='"+avatar_url+"' /></dt>"
                            +"<dd><div class='t'><h5>"+data.data.list[i].user_name+"</h5>"
                            +"<p>"+data.data.list[i].create_time+"</p></div>"
                            +"<div class='c'>"+data.data.list[i].content+"</div></dd></dl><li>"
                    }
                    $('.seller_mes').prepend(result);
                    max_id = data.data.max_id;
                    wrapper.refresh();
                }else{
                    setTimeout(function(){wrapper.refresh();},1000)
                    
                }
            }
        })
    }
    //上拉加载
    function Load() {
        $.ajax({
            url: '/ApiWF/Merch/comments',
            type: 'POST',
            data:{current_page:pageNo,page_size:pageSize,id:id},
            success:function(data){
                if(pageNo<=data.data.total_page){
                    for (i=0; i<data.data.list.length; i++) {
                        var avatar_url = data.data.list[i].avatar;
                        avatar_url = avatar_url.length > 1 ? avatar_url : '/public/H5asset/images/default_avatar.png';

                        result+="<li><dl class='cf'><dt><img src='"+avatar_url+"' /></dt>"
                            +"<dd><div class='t'><h5>"+data.data.list[i].user_name+"</h5>"
                            +"<p>"+data.data.list[i].create_time+"</p></div>"
                            +"<div class='c'>"+data.data.list[i].content+"</div></dd></dl><li>"
                    }
                    $('.seller_mes').append(result);
                    wrapper.refresh();
                    pageNo++;
                }else{
                    setTimeout(function(){
                        $('.pullUpText').text('已经没有更多内容啦！');
                        $(".pullUpIcon").hide();
                        $(".pullUpLabel").hide();
                        wrapper.refresh();
                    },1000)
                }
            }
        })
    }



    Refresh();


</script>
</body>
</html>